Skip to content

Replace export_for_training with torch.export.export #2724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 13, 2025

Conversation

andrewor14
Copy link
Contributor

@andrewor14 andrewor14 commented Aug 8, 2025

Stack from ghstack (oldest at bottom):

Summary: Bypasses the following deprecation warning:

`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.

Bonus: remove some references to capture_pre_autograd_graph,
which is even older.

Test Plan: CI

**Summary:** This commit deprecates the following variables:

```
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8,
which means we can drop support for 2.5 and before since we only
support 3 of the latest releases.

The next commit will remove usages of all of these variables
from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

[ghstack-poisoned]
**Summary:** This commit deprecates the following variables:

```
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

As of this commit, the latest released version of PyTorch is 2.8,
which means we can drop support for 2.5 and before since we only
support 3 of the latest releases.

The next commit will remove usages of all of these variables
from within torchao.

**Test Plan:**
```
python test/test_utils.py -k torch_version_deprecation
```

[ghstack-poisoned]
**Summary:** We gate on the PyTorch version throughout the repo.
Recently PyTorch 2.8 was released, so the oldest PyTorch version
we need to support is 2.6. After this commit, we assume the user
is running PyTorch 2.6+, and remove all references to the following
variables, which are deprecated.

```
TORCH_VERSION_AT_LEAST_2_6
TORCH_VERSION_AT_LEAST_2_5
TORCH_VERSION_AT_LEAST_2_4
TORCH_VERSION_AT_LEAST_2_3
TORCH_VERSION_AT_LEAST_2_2
TORCH_VERSION_AFTER_2_5
TORCH_VERSION_AFTER_2_4
TORCH_VERSION_AFTER_2_3
TORCH_VERSION_AFTER_2_2
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** This commit removes these super old quantization
APIs that aren't even accessible by the user:

```
change_linear_weights_to_int8_dqtensors
change_linear_weights_to_int8_woqtensors
change_linear_weights_to_int4_woqtensors
```

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Aug 8, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2724

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

andrewor14 added a commit that referenced this pull request Aug 8, 2025
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

ghstack-source-id: 6411849
Pull Request resolved: #2724
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 8, 2025
@andrewor14 andrewor14 requested a review from jerryzh168 August 8, 2025 21:31
Copy link
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thanks!

…export.export`"

**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
andrewor14 added a commit that referenced this pull request Aug 8, 2025
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

ghstack-source-id: 6d95765
Pull Request resolved: #2724
@andrewor14 andrewor14 added the topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) label Aug 8, 2025
…export.export`"

**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
andrewor14 added a commit that referenced this pull request Aug 12, 2025
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

ghstack-source-id: 27faec4
Pull Request resolved: #2724
…export.export`"

**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
andrewor14 added a commit that referenced this pull request Aug 12, 2025
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

ghstack-source-id: c51ad80
Pull Request resolved: #2724
…export.export`"

**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
andrewor14 added a commit that referenced this pull request Aug 12, 2025
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

ghstack-source-id: d48c367
Pull Request resolved: #2724
…export.export`"

**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
andrewor14 added a commit that referenced this pull request Aug 12, 2025
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

ghstack-source-id: d7ce94d
Pull Request resolved: #2724
…export.export`"

**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
andrewor14 added a commit that referenced this pull request Aug 12, 2025
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

ghstack-source-id: 64318ec
Pull Request resolved: #2724
…export.export`"

**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

[ghstack-poisoned]
andrewor14 added a commit that referenced this pull request Aug 13, 2025
**Summary:** Bypasses the following deprecation warning:

```
`torch.export.export_for_training` is deprecated and will be removed in PyTorch 2.10.
Please use `torch.export.export` instead, which is functionally equivalent.
```

Bonus: remove some references to `capture_pre_autograd_graph`,
which is even older.

**Test Plan:** CI

ghstack-source-id: 45e8ac6
Pull Request resolved: #2724
@andrewor14 andrewor14 changed the base branch from gh/andrewor14/22/base to main August 13, 2025 14:12
@andrewor14 andrewor14 merged commit 615877d into main Aug 13, 2025
20 of 32 checks passed
andrewor14 added a commit that referenced this pull request Aug 13, 2025
andrewor14 added a commit that referenced this pull request Aug 13, 2025
andrewor14 added a commit that referenced this pull request Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants